<?php
defined("_VALID_ACCESS") || die('Direct access forbidden');
    class Eyeworx_PatientRecords_TransactionInstall extends ModuleInstall {

        public function install() {
            try {
                $type = array(
                    'return'=>'Returned',
                    'sold'=>'Sold'
                );
                Utils_CommonDataCommon::new_array('Eyeworx/PatientRecords/Transaction/type', $type);

                $productClass = array(
                    'frame'=>'Frame',
                    'contactlens'=>'Contact Lens',
                    'lens'=>'Lens',
                    'accessories'=>'Accessories'
                );
                Utils_CommonDataCommon::new_array('Eyeworx/PatientRecords/Transaction/productClass', $productClass);

                $transactions_recordset = new Eyeworx_PatientRecords_Transaction_RBO_RBOTransactions();
                $transactions_recordset->install();
                $transactions_recordset->add_default_access();
                $transactions_recordset->set_caption('Patient Transactions');

                Utils_RecordBrowserCommon::new_addon('eyeworx_patient', 'Eyeworx/PatientRecords/Transaction', 'patient_trans', 'Transactions');

            } catch (Exception $e) {
                return false;
            }
            return true;
        }

        public function uninstall() {
            try {
                Utils_CommonDataCommon::remove('Eyeworx/PatientRecords/Transaction/type');
                Utils_CommonDataCommon::remove('Eyeworx/PatientRecords/Transaction/productClass');

                $transactions_recordset = new Eyeworx_PatientRecords_Transaction_RBO_RBOTransactions();
                $transactions_recordset->uninstall();

                Utils_RecordBrowserCommon::delete_addon('eyeworx_patient', 'Eyeworx/PatientRecords/Transaction', 'patient_trans');
            } catch (Exception $e) {
                return false;
            }
            return true;
        }

        public function requires($v) {
            return array(
                array('name'=>'Base/Lang','version'=>0),
                array('name'=>'Utils/RecordBrowser','version'=>0),
            );
        }

        public function info() {
            return array(
                'Author' => 'Velicaria, Maureen D.',
                'Description' => 'Patient Transaction'
            );
        }

        public function version() {
            return array('1.0');
        }

        public function simple_setup() {
            return array('package'=>__('Eyeworx'), 'option'=>__('Patient Transaction'));
        }

    }
?>